package com.zzedu.web.controller;

import com.zzedu.annon.AccessPermission;
import com.zzedu.common.annotation.Log;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.enums.OperatorType;
import com.zzedu.common.enums.UserTypeEnumns;
import com.zzedu.manager.IZzSendMsgManager;
import com.zzedu.result.Result;
import com.zzedu.stu.req.GetVerificationCode;
import com.zzedu.utils.BaseReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码
 */
@RestController
@AccessPermission(value = {UserTypeEnumns.STUDENT})
public class VerificationCodeController {
    @Autowired
    IZzSendMsgManager zzSendMsgManager;


    /**
     * 获取验证码
     *
     * @return
     */
    @PostMapping(value = {"/getVerificationCode"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "获取验证码", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result getVerificationCode(@Validated @RequestBody BaseReq<GetVerificationCode> baseReq) {
        GetVerificationCode getVerificationCode = baseReq.getData();
        return zzSendMsgManager.sendVerificationCode(getVerificationCode.getPhone(), getVerificationCode.getVerificationCodeEnums());
    }
}
